using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;
using TAAlert.Alerts;

namespace TAAlert.GUI
{
    public partial class RemoveAlert : Form
    {
        private Dictionary<int, Alert> ixToAlertMap = new Dictionary<int, Alert>();
        private AlertManager alertsM;

        public RemoveAlert(AlertManager alerts)
        {
            alertsM = alerts;
            InitializeComponent();

            foreach (Alert a in alertsM.Alerts)
            {
                int ix = clbAlertsM.Items.Add(a.Ticker + " : " + a.Description);
                ixToAlertMap[ix] = a;
            }
        }

        private void removeButtonM_Click(object sender, EventArgs e)
        {
            for (int ix = 0; ix < clbAlertsM.Items.Count; ++ix)
            {
                if (clbAlertsM.GetItemChecked(ix)) // if checked
                {
                    Alert a = ixToAlertMap[ix];
                    alertsM.removeAlert(a);
                }
            }
            this.Close();
        }
    }
}

